package cn.edu.scau.cmi.liuxintong;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import cn.edu.scau.cmi.liuxintong.interProgramming.GraduateStudent;
import cn.edu.scau.cmi.liuxintong.interProgramming.UndergraduateStudent;
import cn.edu.scau.cmi.liuxintong.spring.ApplicationContextUtil;
import cn.edu.scau.cmi.liuxintong.spring.Student;
import cn.edu.scau.cmi.liuxintong.spring.Teacher;
import javafx.application.Application;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.effect.DropShadow;
import javafx.scene.layout.AnchorPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class SpringBaseUse extends Application{
	private static Teacher liangzaoqing;
	private static Student zhangsan;
	public SpringBaseUse() {
	}
	 static TextArea textArea = new TextArea();
	@Override
	public void start(Stage primaryStage) throws Exception {
		// TODO Auto-generated method stub
		AnchorPane anchorPane = new AnchorPane();
		DropShadow dropshadow = new DropShadow();
		dropshadow.setColor(Color.PALEVIOLETRED);
		dropshadow.setOffsetX(5.0);
		dropshadow.setOffsetY(5.0);
		dropshadow.setRadius(10.0);
		Text experimentName = new Text("Spring基本使用");//ok
		experimentName.setEffect(dropshadow);
		experimentName.setFont(Font.font(" Verdana",FontPosture.ITALIC,40));
		TextField textField = new TextField();
		textArea.setPrefHeight(330);
		textArea.setPrefWidth(780);
		 Button Springbaseuse = new Button("输出张三的导师");
		 Springbaseuse.setOnAction(new EventHandler() {
			  public void handle(Event event) {
				  list();  
			  }});
		 anchorPane.getChildren().addAll(experimentName,textField,textArea,Springbaseuse);
	     AnchorPane.setLeftAnchor(experimentName, 275.0);
		 AnchorPane.setBottomAnchor(experimentName,400.0);//下
		 AnchorPane.setLeftAnchor(textField, 140.0);
		 AnchorPane.setLeftAnchor( Springbaseuse, 450.0);
		 AnchorPane.setBottomAnchor( Springbaseuse,350.0);//下
		 AnchorPane.setBottomAnchor(textField,470.0);//下
		 AnchorPane.setLeftAnchor(textArea, 10.0);
		 AnchorPane.setBottomAnchor(textArea,10.0);
		 primaryStage.setScene(new Scene(anchorPane, 800,450));
	     primaryStage.show();
	}
	public static void main(String[] args) {
		launch(args);
	}
	 public static void list() {
		 ApplicationContext applicationContext =new ClassPathXmlApplicationContext("applicationContext.xml");
		 Student student1 = (Student) applicationContext.getBean("zhangsan");
         textArea.appendText(student1.getName() + "的毕业设计指导导师是：" + student1.getTeacher().getName());
         textArea.appendText("\n");
	 }
}
